%global __provides_exclude_from %{_libdir}/%{name}
%global __requires_exclude ^lib(ffmpeg|EGL|GLES|vk_swiftshader|vulkan)

Name:    vscode
Version: 1.83.1
Release: 1

Summary: Open source source code editor developed by Microsoft for Windows, Linux and macOS

License: MIT 
Group:   Development/Other
Url:     https://github.com/microsoft/vscode

%ifarch x86_64
Source0: https://update.code.visualstudio.com/%{version}/linux-x64/stable?/code-stable-x64-%{version}.tar.gz
%endif
%ifarch aarch64
Source1: https://update.code.visualstudio.com/%{version}/linux-arm64/stable?/code-stable-arm64-%{version}.tar.gz
%endif

Source2: vscode.desktop
Source3: code.png

%description
Open source source code editor developed by Microsoft for Windows,
Linux and macOS. It includes support for debugging, embedded Git
control, syntax highlighting, intelligent code completion, snippets,
and code refactoring. It is also customizable, so users can change the
editor's theme, keyboard shortcuts, and preferences

%files
%_bindir/%name
%_bindir/code
%_libdir/%name/
%_datadir/applications/%name.desktop
%_datadir/pixmaps/code.png

%prep
%ifarch x86_64
    tar -xf %SOURCE0
%endif
%ifarch aarch64
    tar -xf %SOURCE1
%endif

%build
#

%install
mkdir -p %buildroot%_libdir/%name/
%ifarch x86_64
    cp -r %_builddir/VSCode-linux-x64/* %buildroot%_libdir/%name/
%endif
%ifarch aarch64
    cp -r %_builddir/VSCode-linux-arm64/* %buildroot%_libdir/%name/
%endif

mkdir -p %buildroot%_bindir/
ln -rs %buildroot%_libdir/%name/bin/code %buildroot/%_bindir/code
ln -rs %buildroot%_libdir/%name/bin/code %buildroot/%_bindir/vscode

install -m644 -D %SOURCE2 %buildroot%_datadir/applications/%name.desktop
install -m644 -D %SOURCE3 %buildroot%_datadir/pixmaps/code.png
